package com.parkingspace.controller;


import com.parkingspace.entity.Property;
import com.parkingspace.service.IUserService;
import com.parkingspace.util.Constants;
import com.parkingspace.util.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author Gapper
 * @since 2021-05-24
 */
@RestController
@RequestMapping("/user")
public class UserController {

	@Resource
	private IUserService iUserService;

	/**
	 * 根据登录的用户返回当前用户的物业公司信息
	 * @param token 传入token
	 * @return 返回Property
	 */
	@GetMapping("/findByProperty/{token}")
	public ResultVO findByProperty (@PathVariable("token") String token) {
		try {
			Property byProperty = iUserService.findByProperty(token);
			return new ResultVO(Constants.OPER_SUCCESS,"查询成功!",byProperty);
		} catch (Exception e) {
			e.printStackTrace();
			return new ResultVO(Constants.OPER_FAILURE,e.getMessage(),"查询失败!");
		}
	}



}

